package com.taxshare.seller.timer;

import cn.hutool.core.util.StrUtil;
import com.taxshare.seller.service.InvoicedService;
import com.taxshare.seller.view.dto.SynchronizeInvoiceDTO;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import com.xxl.job.core.log.XxlJobLogger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @ClassName: InvoiceHandler
 * @Description:
 * @author: Hai
 * @date: 2021/5/31 15:25
 */
@Component
public class InvoiceHandler {

    @Autowired
    private InvoicedService invoicedService;

    @XxlJob("syncInvoice")
    public ReturnT<String> execute(String sellerTaxNo) {
        Date date=new Date();
        String format = new SimpleDateFormat("yyyy-MM-dd").format(date);
        String formatDay = new SimpleDateFormat("dd").format(date);
        String formatMonth = new SimpleDateFormat("MM").format(date);
        String formatYear = new SimpleDateFormat("yyyy").format(date);
        System.out.println("==>全"+format);
        System.out.println("==>全"+formatDay);
        System.out.println("==>全"+formatMonth);
        System.out.println("==>全"+formatYear);

        if(StrUtil.isBlank(sellerTaxNo)){
            sellerTaxNo = "91110000739352098T";
        }
        SynchronizeInvoiceDTO dto = new SynchronizeInvoiceDTO();
        dto.setSellerTaxNo(sellerTaxNo);
        invoicedService.syncInvoice(dto);
        return ReturnT.SUCCESS;
    }
}
